package com.example.myapplicationdemo01.slice;

import com.example.myapplicationdemo01.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.Text;

public class MainAbilitySlice2 extends AbilitySlice {

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        // 定义slice视图组件（java,xml）
        // setUIContent(int); 加载应用的 布局文件（xml）作为当前slice的试图
//        super.setUIContent(ResourceTable.Layout_ability_main_slice2);

        // ComponentContainer（组件容器）
        DirectionalLayout directionalLayout = new DirectionalLayout(this);
        directionalLayout.setOrientation(Component.DRAG_VERTICAL);
        // Component（组件）
        Text text = new Text(this);
        text.setText("Hello Boys");
        text.setHeight(40);
        text.setTextSize(40);
        // 将组件放到组件容器中
        directionalLayout.addComponent(text);
        // 将组件容器渲染到slice中
        setUIContent(directionalLayout);
    }
}
